package b2.scene.fight.skills
{
	import b2.scene.fight.TankSprite;

	public class EffectAddSkill extends BasicSkill
	{
		public function EffectAddSkill(tankId:int, tankSide:int ,level:int, skillArgs:Object)
		{
			super(tankId, tankSide ,level, skillArgs);
		}
		
		public override function checkSkillTriggerPremise(x:int, y:int, direction:int):Boolean
		{
			var tank:TankSprite = getPlayState().tanks[tankId];
			//加血
			if (this.skillArgs["effectIndex"] == 4)
			{
				if (tank.currentHp >= tank.healthPoint)
					return false;
			}
			//无敌
			if (this.skillArgs["effectIndex"] == 0)
			{
				if (tank.currentHp >= tank.healthPoint)
					return false;
			}
			return super.checkSkillTriggerPremise(x, y, direction);
		}
		
		public override function discharge(x:int, y:int, direction:int):void
		{
			var effectValue:int = level < skillArgs.effectValue.length ? skillArgs.effectValue[level] : skillArgs.effectValue[0] * level;
			var effectValue2:int = level < skillArgs.effectValue2.length ? skillArgs.effectValue2[level] : skillArgs.effectValue2[0] * level;
			getPlayState().addTankEffect(tankId, -1, skillArgs.effectIndex, skillArgs.effectDuration[0], effectValue, effectValue2);
			super.discharge(x, y, direction);
		}
	}
}